package com.solt.prism.dao.imp;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;

import com.solt.prism.core.entity.News;
import com.solt.prism.core.similar.DocSimilar;
import com.solt.prism.dao.CategoriesDao;
import com.solt.prism.dao.JosContent;
import com.solt.prism.dao.JosContentFrontPage;

public class JosDao implements JosContentFrontPage ,JosContent {
	public static Logger logger = Logger.getLogger(JosDao.class);
	private JosContent content;
	private JosContentFrontPage frontPage;	
	
	public JosDao() throws SQLException {
		content = JosContentSqlServerVersionImp.getJosContent();
	}
	
	@Override
	public int insertNews(News news, List<DocSimilar> relateNews) {
		if (!CategoriesDao.getInstance(true).isContain(news.getCatId())) {
			logger.warn("Category in this new doesn't exist :" + news.toString());
			return -1;
		}
			
		return content.insertNews(news,relateNews);
	}
	
	@Override
	public int insertNews(News news, int[] relateNews) {
		 return content.insertNews(news);
	}
	
	
	
	@Override
	public int insertNews(News news) {
		return content.insertNews(news);
	}
	
	
	@Override
	public int insertFrontPage(int newId, int order) {
		return frontPage.insertFrontPage(newId, order);
	}
	
}
